/**   
 * 项目名：化工企业安全生产信息化管理平台
 * 日期：    2020-06-28 02:01:43  
 * Copyright (c) 2015- -版权所有     
 */

package com.joysuch.wwyt.audit.entity;

import static javax.persistence.GenerationType.IDENTITY;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

import com.joysuch.wwyt.core.support.AutoSetCommonFieldListener;
import lombok.Data;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.Where;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

@EntityListeners({ AuditingEntityListener.class, AutoSetCommonFieldListener.class })
@Entity
@Table(name = "wwyt_audit_log_action_def")
@SQLDelete(sql = "update wwyt_audit_log_action_def set DELETE_FLAG = '1' where id= ?")
@SQLDeleteAll(sql = "update wwyt_audit_log_action_def set DELETE_FLAG = '1' where id= ?")
@Where(clause = "DELETE_FLAG = '0'")
@Data
public class AuditLogActionDef implements java.io.Serializable {

    // columns START
    @Id
    @GeneratedValue(strategy = IDENTITY)

    // ID
    @Column(name = "ID", unique = true, nullable = false)
    private Long id;

    @Column(name = "TENENT_ID")
    private Long tenentId;

    @Column(name = "ORG_CODE", length = 100)
    private String orgCode;
    // 编号
    @Column(name = "CODE", length = 10, nullable = false)
    private String code;

    // 名称
    @Column(name = "NAME", length = 100, nullable = false)
    private String name;

    // 所属模块
    @Column(name = "MODULE", length = 30, nullable = false)
    private String module;

    // 操作名称
    @Column(name = "OPERATION_NAME", length = 50, nullable = false)
    private String operationName;

    // 触发类型
    @Column(name = "TRIGGER_TYPE", length = 10, nullable = false)
    private String triggerType;

    // 触发值
    @Column(name = "TRIGGER_VALUE", length = 500, nullable = false)
    private String triggerValue;

    // 分组标识
    @Column(name = "GROUP_ID", length = 20)
    private String groupId;

    // 分组顺序
    @Column(name = "GROUP_ORDER")
    private Integer groupOrder;

    // 执行结果判断类型
    @Column(name = "RESULT_JUDGE_TYPE", length = 10, nullable = false)
    private String resultJudgeType;

    // 执行结果判断规则
    @Column(name = "RESULT_JUDGE_RULE", length = 65535, nullable = false)
    private String resultJudgeRule;

    // 操作对象类型
    @Column(name = "OP_OBJECT_TYPE", length = 100)
    private String opObjectType;

    // 获取对象方法
    @Column(name = "QUERY_OBJECT_METHOD", length = 10)
    private String queryObjectMethod;

    // 获取对象参数
    @Column(name = "QUERY_OBJECT_PARAMS", length = 65535)
    private String queryObjectParams;

    // 状态
    @Column(name = "STATE", nullable = false)
    private Integer state;

    // 描述
    @Column(name = "DESCRIPTION", length = 65535)
    private String description;

    // 创建人
    @org.springframework.data.annotation.CreatedBy
    @Column(name = "CREATE_BY")
    private Long createBy;

    // 创建时间
    @org.springframework.data.annotation.CreatedDate
    @Column(name = "CREATE_TIME")
    private java.util.Date createTime;

    // 更新人
    @org.springframework.data.annotation.LastModifiedBy
    @Column(name = "UPDATE_BY")
    private Long updateBy;

    // 更新时间
    @org.springframework.data.annotation.LastModifiedDate
    @Column(name = "UPDATE_TIME")
    private java.util.Date updateTime;

    // 删除标记
    @Column(name = "DELETE_FLAG", length = 2)
    private String deleteFlag;

    @Column(name = "OP_TYPE", length = 10)
    private String opType;

    @Column(name = "OP_OBJECT_NAME_ATTR", length = 50)
    private String opObjectNameAttr;

    // columns END

    public int hashCode() {
        return new HashCodeBuilder()
                .append(getId())
                .toHashCode();
    }

    public boolean equals(Object obj) {
        if (obj instanceof AuditLogActionDef == false)
            return false;
        if (this == obj)
            return true;
        AuditLogActionDef other = (AuditLogActionDef) obj;
        return new EqualsBuilder()
                .append(getId(), other.getId())
                .isEquals();
    }
}
